Add -vs status indicator to most file formats.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 16 Jan 2004 03:50:37 +0000 (03:50 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 16 Jan 2004 03:50:37 +0000 (03:50 +0000)
Fix magellan serial timeouts under Windows.

gpsbabel/Makefile
gpsbabel/defs.h
gpsbabel/garmin.c
gpsbabel/magproto.c
gpsbabel/main.c
gpsbabel/waypt.c

index 368c5587919e2ac0750662a442ac557c8f0d957f..a3c32d4c5415eee5e130f8eb534f0ee5165604eb 100644 (file)
@@ -78,8 +78,8 @@ dep:
        (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)' ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_2_1_beta01112004
-VERSIOND=1.2.1_beta01112004
+VERSIONU=1_2_1_beta01152004
+VERSIOND=1.2.1_beta01152004
 #VERSIONU=1_2_1
 #VERSIOND=1.2.1
 
index 8c96609d3565aa8e4a40464ae6e70ce75013d2b4..cb08cbbc5461a20eae668d851a351326c540428a 100644 (file)
@@ -63,6 +63,7 @@ typedef struct {
        int synthesize_shortnames;
        int debug_level;
        gpsdata_type objective;
+       int verbose_status;     /* set by GUI wrappers for status */
 } global_options;
 
 extern global_options global_opts;
index 7d8dbc2defaf03b055fa0269de892a33a479101a..51d3beb1f3c4bbd634b1ac00796b6b3380bdea36 100644 (file)
@@ -350,6 +350,10 @@ waypoint_write(void)
                if (wpt->altitude != unknown_alt) {
                        way[i]->alt = wpt->altitude;
                }
+               if (global_opts.verbose_status) {
+                       fprintf(stdout, "%d\r", i*100/n);
+                       fflush(stdout);
+               }
                i++;
        }
        if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) {
@@ -359,6 +363,9 @@ waypoint_write(void)
        for (i = 0; i < n; ++i) {
                GPS_Way_Del(&way[i]);
        }
+       if (global_opts.verbose_status) {
+               fprintf(stdout, "\r\n");
+       }
        xfree(way);
 }
 
index fb1c6bce136ec810076371aad57ffedf6ece0e41..56c65d167ede1984aece188035b25fa78fd070ee 100644 (file)
@@ -549,8 +549,10 @@ terminit(const char *portname)
        }
 
        GetCommTimeouts (comport, &timeout);
-       timeout.ReadIntervalTimeout = 10;
-       timeout.WriteTotalTimeoutMultiplier = 10;
+       timeout.ReadIntervalTimeout = 100;
+       timeout.ReadTotalTimeoutMultiplier = 100;
+       timeout.ReadTotalTimeoutConstant = 100;
+       timeout.WriteTotalTimeoutMultiplier = 100;
        timeout.WriteTotalTimeoutConstant = 1000;
        if (!SetCommTimeouts (comport, &timeout)) {
                xCloseHandle (comport);
@@ -573,11 +575,13 @@ termread(char *ibuf, int size)
        for(;i < size;i++) {
                if (ReadFile (comport, &ibuf[i], 1, &cnt, NULL) != TRUE)
                        break;
-               if (ibuf[i] == '\n') break;
+               if (cnt < 1) 
+                       return NULL;
+               if (ibuf[i] == '\n') 
+                       break;
        }
        ibuf[i] = 0;
        return ibuf;
-
 }
 
 static void
index 704336c45cf960651587108f969d9a571195d5af..6c63cccc62a7522939f8ca62dc8a65778d191115 100644 (file)
@@ -186,6 +186,15 @@ main(int argc, char *argv[])
                                        ? argv[argn]+2 : argv[++argn];
                                global_opts.debug_level = atoi(optarg);
                                break;
+                               /*
+                                * Undocumented '-vs' option for GUI wrappers.
+                                */
+                       case 'v':
+                               switch(argv[argn][2]) {
+                               case 's': global_opts.verbose_status = 1; break;
+                               }
+                               break;
+
                                /*
                                 * DOS-derived systems will need to escape
                                 * this as -^^.
index 5e2831db6e3457ea4edd3798d3f4d8feb20420ea..8e082d6a184429af7fc334abfd4271aa01738de3 100644 (file)
@@ -137,11 +137,19 @@ waypt_disp_all(waypt_cb cb)
 {
        queue *elem, *tmp;
        waypoint *waypointp;
+       int i = 0;
 
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                waypointp = (waypoint *) elem;
+               if (global_opts.verbose_status) {
+                       fprintf(stdout, "%d\r", ++i*100/waypt_ct);
+                       fflush(stdout);
+               }
                (*cb) (waypointp);
        }
+       if (global_opts.verbose_status) {
+               fprintf(stdout, "\r\n");
+       }
 }
 
 waypoint *